import {_post, _get} from '../util/http'
import axios from '../axios/index'
import qs from 'qs'

// 获取token
const getApiToken = (obj) => {
  return new Promise((resolve, reject) => {
    // _post('/dinner/shop.token/get', qs.stringify(obj))
    //   .then(data => {
    //     resolve(data)
    //   })
    //   .catch(err => {
    //     reject(err)
    //   })
    axios.post('/dinner/shop.token/get', qs.stringify(obj))
      .then(data => {
        resolve(data.data)
      })
      .catch(err => {
        reject(err)
      })
  })
}
// 获取商品列表
const getGoodsList = (obj) => {
  return new Promise((resolve, reject) => {
    _post('/dinner/shop.goods/lists', qs.stringify(obj))
      .then(data => {
        resolve(data)
      })
      .catch(err => {
        reject(err)
      })
  })
}

// 获取商品详情
const getGoodInfo = (obj) => {
  return new Promise((resolve, reject) => {
    _post('/dinner/shop.goods/info', qs.stringify(obj))
      .then(data => {
        resolve(data)
      })
      .catch(err => {
        reject(err)
      })
  })
}
export default {
  getApiToken,
  getGoodsList,
  getGoodInfo
}